package com.craterhill.java.ccp.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.craterhill.java.ccp.common.beans.Department;

import com.craterhill.java.ccp.dao.impl.AbstractDao;
import com.craterhill.java.ccp.dao.utils.CCPResultSetExtractor;

public interface DepartmentDao extends CCPDao<Department> {
	public final String FIELD_LIST = "obj.college_id, obj.course_id, obj.department_id, obj.department_name, obj.duration, obj.study_type_id" 
		+ AbstractDao.MONITER_FIELDS;

	public final String FIND_ALL_DEPARTMENT = "select " + FIELD_LIST + " from department obj ";

	public final class DepartmentExtractor extends CCPResultSetExtractor<Department> {

		@Override
		protected Department extractResultSetData(ResultSet resultSet) throws SQLException {
			Department department = new Department();
			department.setCollegeId(resultSet.getInt(1));
			department.setCourseId(resultSet.getInt(2));
			department.setDepartmentId(resultSet.getInt(3));
			department.setDepartmentName(resultSet.getString(4));
			department.setDuration(resultSet.getInt(5));
			department.setStudyTypeId(resultSet.getInt(6));
			department.setStatus(resultSet.getBoolean(7));
			department.setCreatedBy(resultSet.getInt(8));
			department.setModifiedBy(resultSet.getInt(9));
			department.setCreatedDate(resultSet.getDate(10));
			department.setModifiedDate(resultSet.getDate(11));
			return department;
		}

	}
}
